﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EzDesk.Utility.Extensions;
using NUnit.Framework;

namespace EzDesk.Utility.UnitTest
{
    [TestFixture]
    public class DateTimeExtensionFixture
    {
        [Test]
        public void Test_ToNiceTimeMethod()
        {
            DateTime now = DateTime.Now;
            DateTime time1 = now.AddSeconds(-20);
            DateTime time2 = now.AddMinutes(-3);
            DateTime time3 = now.AddMinutes(-30);
            DateTime time4 = now.AddHours(-3);
            DateTime time5 = now.AddDays(-1);
            DateTime time6 = now.AddDays(-2);
            DateTime time7 = now.AddDays(-4);
            DateTime time8 = now.AddYears(-2);

            Assert.AreEqual(time1.ToNiceTime(), "刚刚");
            Assert.AreEqual(time2.ToNiceTime(), "3 分钟前");
            Assert.AreEqual(time3.ToNiceTime(), "30 分钟前");
            Assert.AreEqual(time4.ToNiceTime(), "3 小时前");
            Assert.AreEqual(time5.ToNiceTime(), "昨天 " + now.Hour + ":" + now.Minute);
            Assert.AreEqual(time6.ToNiceTime(), "前天 " + now.Hour + ":" + now.Minute);
            Assert.AreEqual(time7.ToNiceTime(), time7.ToShortDateTime());
            Assert.AreEqual(time8.ToNiceTime(), time8.ToFullDateTime());

            return;
        }
    }
}
